package internalAPI;

/**
 * This class serves as mediator for running the query throught the database
 * @author Lukas Rucka, Masaryk University, Brno, Czech Republic, xrucka@fi.muni.cz
 */
public class Query {

    /**
     * Coordinates to search near to
     */
    private LatLng nearTo;

    /**
     * Radius for near neighbour search in meters
     */
    private float radiusNear;

    /**
     * String to match in fulltext search
     */
    private String fulltext;

    /**
     * String to match in name
     */
    private String name;

    /**
     * Type of object to search for
     */
    private ObjectType type;

    /**
     * Possible object types to search for
     */
    public enum ObjectType {CAVE, BASEMENT, SEWER, ABYSS };

    /**
     * Gets the fulltext to search for
     * @return null if not set
     */
    public String getFulltext() {
        return fulltext;
    }

    /**
     * Sets the fulltext to search for
     * @param fulltext - null if search according to this is disabled
     */
    public void setFulltext(String fulltext) {
        this.fulltext = fulltext;
    }

    /**
     * Gets object name to search for
     * @return null if not set
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name to search for
     * @param name - null if search according to this is disabled
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Gets coordinates to search near objects for
     * @return null if not set
     */
    public LatLng getNearSearchCoordinates() {
        return nearTo;
    }

    /**
     * Sets the coordinates and radius to search near objects for
     * @param nearTo - null if search according to this is disabled
     * @param nearTo - radius in meters, negative values will be treated as zero
     */
    public void setNearSearch(LatLng nearTo, float radius){
        this.nearTo = nearTo;
        if (radius < 0){ radius = 0; }
        this.radiusNear = radius;
    }

    /**
     * Gets radius of near search
     * @return radius in meters, indenpendent on whether near search is enabled
     */
    public float getNearSearchRadius() {
        return radiusNear;
    }

    /**
     * Get object type to search for
     * @return null if not set
     */
    public ObjectType getType() {
        return type;
    }

    /**
     * Sets object type to search for
     * @param type - null if search according to this is disabled
     */
    public void setType(ObjectType type) {
        this.type = type;
    }


};
